#!/usr/bin/python

import sys
import matplotlib.pyplot as plt
import pylab
import numpy as np

filename = sys.argv[1]
f = open(filename, "rU")
fl = f.readlines()
#outfile = sys.argv[2]

x1 = []
x2 = []
y = []

line = fl[4]
l = line.split('\t')
genome_size = int(l[7])

genome_coords = {}

for i in range(1, genome_size+1):
    genome_coords[i] = 0

for i, line in enumerate(fl[4:]):
    l = line.split('\t')
    start = int(l[0])
    stop = int(l[1])
    gs = int(l[7])
    identity = float(l[6])
    x1.append(start)
    x2.append(stop)
    y.append(identity)

a = [x1, x2]
b = [y, y]

gx = [1,genome_size]
gy = [10,10]

xcoords = range(1, genome_size+1)

print "Plotting..."

fig = plt.figure(1, figsize=(14,6))

plt.plot(gx, gy, color='#666600', marker='|', markersize=8.0,
    markeredgecolor='black', linestyle='-', linewidth=2.0)
plt.plot(a, b, color='purple', linestyle='-', linewidth=1.5)
plt.axis([0, genome_size, 0, 110])
plt.title('Recruitment plot')
plt.ylabel('% Identities')
plt.grid(True)


plt.show()

